﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;

namespace SPRepoDemo.Web.Helpers
{
    public class WebHelper
    {
        public static SPWeb GetWeb(string webName)
        {
            return GetWeb(SPContext.Current.Web, webName);
        }

        public static SPWeb GetWeb(SPWeb web, string webName)
        {
            if (web != null)
            {
                if (web.Title == webName)
                {
                    return web;
                }
                var adminWeb = web.Site.AllWebs[webName];
                if (adminWeb.Exists)
                {
                    return adminWeb;
                }
                //CreateSiteHelper.CreateBlankSubSite(web.Site.RootWeb, webName);
                adminWeb = web.Site.AllWebs[webName];
                return adminWeb;
            }
            return null;
        }
    }
}
